<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增公告类型')" />
	<th:block th:include="include :: datetimepicker-css" />
	<script th:src="@{/js/jquery.min.js}"></script>
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">

			<div class="form-group">
				<label class="col-sm-3 control-label">任务标题：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="taskTitle" id="taskTitle" required>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">开始时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="taskStartTime" name="taskStartTime" placeholder="yyyy-MM-dd HH:mm:ss" style="width:180px">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">完成时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="taskStopTime" name="taskStopTime" placeholder="yyyy-MM-dd HH:mm:ss" style="width:180px">
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-3 control-label">归属部门：</label>
				<div class="col-sm-8">
					<input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control" required>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">执行人员：</label>
				<div class="col-sm-8">
					<select class="form-control" id="selectBydeptId" name="taskUserId">
					</select>
				</div>
			</div>
<!--			<input type="hidden" id="taskUser">-->
			<div class="form-group">
				<label class="col-sm-3 control-label">紧急程度：</label>
				<div class="col-sm-8">
					<label class="radio-box"> <input type="radio" name="taskType" value="0" /> 一般 </label>
					<label class="radio-box"> <input type="radio" name="taskType" value="1" /> 紧急 </label>
					<label class="radio-box"> <input type="radio" name="taskType" value="2" /> 非常紧急 </label>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">任务内容：</label>
				<div class="col-sm-8">
					<textarea id="taskContent" name="taskContent" class="form-control"></textarea>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">选择文件：</label>
				<div class="col-sm-8">
					<input class="form-control" type="file" name="taskFile" id="taskFile">
				</div>
			</div>

		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<script type="text/javascript">
		var prefix = ctx + "schedule/task";

		function submitHandler() {
			if ($.validate.form()) {
				$.operate.save(prefix + "/add", $('#form-post-add').serialize());
			}
		}

		/*用户管理-新增-选择部门树*/
		function selectDeptTree() {
			var treeId = $("#treeId").val();
			var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
			var url = ctx + "system/dept/selectDeptTree/" + deptId;
			var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		function doSubmit(index, layero){

			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			if ($.tree.notAllowParents(tree)) {
				var body = layer.getChildFrame('body', index);
				$("#treeId").val(body.find('#treeId').val());
				$("#treeName").val(body.find('#treeName').val());


				$("#selectBydeptId").empty();
				$.get(ctx + "schedule/task/selectByDeptId",{deptId:body.find('#treeId').val()},function(data,status){
					for(var i in data){
						$("#selectBydeptId").append("<option value="+data[i].userId+">"+data[i].loginName+'---'+data[i].userName+"</option>");
					}

				});

				layer.close(index);
			}
		}

		$(function () {
			$("#taskStartTime").datetimepicker({
				format: "yyyy-mm-dd hh:ii:ss",
				autoclose: true
			});
			$("#taskStopTime").datetimepicker({
				format: "yyyy-mm-dd hh:ii:ss",
				autoclose: true
			});
		})
	</script>

</body>
</html>
